import java.util.Properties;

import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

/**
 * Simple demonstration of using the javax.mail API.
 * 
 * Run from the command line. Please edit the implementation to use correct
 * email addresses and host name.
 */
public final class Emailer {
	final static String username = "chriswangh@gmail.com";
	final static String password = "82117770";

	public static void main(String args[]) {
		Properties props = new Properties();
		props.put("mail.smtp.auth", "true");
		props.put("mail.smtp.starttls.enable", "true");
		props.put("mail.smtp.host", "smtp.gmail.com");
		props.put("mail.smtp.port", "587");
		Authenticator authenticator = new Authenticator() {
			protected PasswordAuthentication getPasswordAuthentication() {
				return new PasswordAuthentication(username, password);

			}
		};
		Session session = Session.getInstance(props, authenticator);
		try {
			Message message = new MimeMessage(session);
			message.setFrom(new InternetAddress(username));
			message.setRecipients(Message.RecipientType.TO,
					InternetAddress.parse("thefirechris@gmail.com"));
			message.setSubject("my first email");
			message.setContent("adsf", "text/html;charset=utf-8");
			Transport.send(message);
			System.out.println("done");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}